public class ControlThread extends Thread {
    public ControlThread(String name) {
        super(name);
    }

    public void run() {
        loop();
    }

    public void loop() {
        String name = Thread.currentThread().getName();
        System.out.println("进入循环函数：" + name);
        for (int i = 0; i < 3; i++) {
            try {
                Thread.sleep(2000);
            } catch (InterruptedException x) {
                System.out.println("线程被打断了");
            }
            System.out.println("线程名:" + name);
        }
        System.out.println("离开循环函数:" + name);
    }

    public static void main(String args[]) {
        ControlThread tn = new ControlThread("我的线程");
        tn.start();
        tn.interrupt();
            try {
                tn.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            tn.loop();
    }
}